
<script language="javascript" type="text/javascript" src="/assets/My97DatePicker/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript" src="/assets/libs/fastadmin-layer/dist/layer.js"></script>
<div class="content">
    <div style="padding: 0 10px;font-size: 14px;height: 40px;line-height: 40px;">
        <a href="/admin/product/index">产品列表</a>
    </div>
<div class="panel panel-default panel-intro">
    <div class="panel-body">
        <div id="" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div class="bootstrap-table">
                        <div class="fixed-table-toolbar">
                            <div class="bs-bars pull-left">

                                <?php if ($_SESSION['think']['admin']['id']==1){?>
                               <div id="toolbar" class="toolbar" style="position: relative;">
                                    <a href="{:url('info_add',array('pid'=>$pid,'fid'=>0))}" class="btn btn-success btn-add " title="添加"><i class="fa fa-plus"></i> 添加</a>
                                </div>

                                <?php } ?>
                            </div>
                         <!--  <form action="" method="post">-->
                                <table  class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="1" data-operate-del="1" width="100%" border="1">
                                    <thead>
                                    <tr>
                                        <!--<th style=" text-align: center;vertical-align: middle;width:12%;" data-field="info_order">
                                            <div class="th-inner ">排序</div>
                                            <div class="fht-cell"></div>
                                        </th>-->
                                        <th style="text-align: center; vertical-align: middle;width:4.5%;" data-field="id">
                                            <div class="th-inner "></div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:4.5%;" data-field="id">
                                            <div class="th-inner ">父ID</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:4.5%;" data-field="id">
                                            <div class="th-inner ">ID</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:4.5%;" data-field="info_type">
                                            <div class="th-inner ">产品信息类别</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:15%;" data-field="title">
                                            <div class="th-inner ">标题</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:6%;" data-field="status">
                                            <div class="th-inner ">状态</div>
                                            <div class="fht-cell"></div>
                                        </th>

                                        <th style="text-align: center; vertical-align: middle;width: 20%;" data-field="operate">
                                            <div class="th-inner ">操作</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody data-listidx="0">
                                    {volist name="list" id="vo"}
                                    <tr data-index="0" onclick="">
                                        <!--<td style=" text-align: center; vertical-align: middle;">
                                          <input type="number"  infoid="{$vo['id']}"   no="mainorder"  min="0" name="father[{$vo['id']}]" value="{$vo.info_order}" style="width:40px;" id="fSort_{$vo.id}"/>
                                        </td>-->
                                        <td style="text-align: center; vertical-align: middle; ">

                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$vo.fid}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$vo.id}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; "><!--info_type-->
                                             {$info_type[$vo['info_type']]}
                                        </td>
                                        <td style=" vertical-align: middle; ">
                                            {$vo.title}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            <span dt_1="{$vo.id}"  onclick="changeStatus(this); " {if condition="$vo.status eq 0"} class="btn btn-success" {else/} class="btn btn-danger"{/if}> {if condition="$vo.status eq 0"}显示{else/} 隐藏{/if}</span>
                                        </td>

                                        <td style="text-align: center; vertical-align: middle; ">
                                            <a href="{:url('info_add',array('pid'=>$pid,'fid'=>$vo['id']))}" class="btn btn-success btn-edit btn-disabled" title="添加"><i class="fa fa-pencil"></i> 添加</a>
                                            <a href="{:url('info_edit',array('id'=>$vo['id']))}" class="btn btn-success btn-edit btn-disabled" title="编辑"><i class="fa fa-pencil"></i> 修改</a>
                                            <?php if ($_SESSION['think']['admin']['id']==1){?>
                                            <a href="{:url('info_del',array('id'=>$vo['id']))}" class="btn btn-success btn-del" title="删除"><i class="fa fa-trash"></i> 删除</a>
                                            <?php } ?>

{if condition="$vo.info_type eq 1"}
                                            <a href="javascript:void(0)" onclick="addImg({$vo['id']}); " class="btn btn-success btn-del" title="图片管理"><i class="fa fa-plus"></i> 图片管理</a>{/if}
                                        </td>
                                    </tr>
                                    <form action="" method="post">
                                    {volist name="$vo['child']" id="v1"}
                                    <tr data-index="0" onclick="">
                                      <!-- <td style="text-align: center; vertical-align: middle; ">

                                        </td>-->
                                        <td style="text-align: center; vertical-align: middle; ">
                                            <input type="number" min="0" name="{$v1.id}" value="{$v1.info_order}" style="width:40px;"/>
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$v1.fid}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$v1.id}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; "><!--info_type-->
                                            {$info_type[$v1['info_type']]}
                                        </td>
                                        <td style="vertical-align: middle; ">
                                          &nbsp; ----------{$v1.title}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            <span dt_1="{$v1.id}"  onclick="changeStatus(this); " {if condition="$v1.status eq 0"} class="btn btn-success" {else/} class="btn btn-danger"{/if}> {if condition="$v1.status eq 0"}显示{else/} 隐藏{/if}</span>

                                        </td>

                                        <td style="text-align: center; vertical-align: middle; ">

                                            <a href="{:url('info_edit',array('id'=>$v1['id']))}" class="btn btn-success btn-edit btn-disabled" title="编辑"><i class="fa fa-pencil"></i> 修改</a>
                                            <a href="{:url('info_del',array('id'=>$v1['id']))}" class="btn btn-success btn-del" title="删除"><i class="fa fa-trash"></i> 删除</a>
                                           <!-- <a href="javascript:void(0)" onclick="addImg({$v1['id']}); " class="btn btn-success btn-del" title="图片管理"><i class="fa fa-plus"></i> 图片管理</a>-->
                                        </td>
                                    </tr>


                                    {/volist}
                                   <tr>
                                        <td colspan="7" style="padding-left:10px; ">
                                            <input type="submit" value="排序" class="group_btn" />
                                        </td>
                                    </tr>
                                    </form>
                                    {/volist}

                                    </tbody>
                                    <!--<tr>
                                        <td colspan="8" style="padding-left:105px; ">
                                            <button onclick="fatherSub('{$pid}');">排序</button>
                                        </td>
                                    </tr>-->
                                </table>
                         <!--  </form>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<form id="mainorder" action="" method="post">

</form>




<script>
    function changeStatus(o){
        var id=$(o).attr("dt_1");
        $.ajax({
            type:"post",
            dataType:"json",
            data:{"id":id},
            url:"/admin/product/changeStatus",
            success:function(data){
                if(data==1){
                    $(o).attr("class",'btn btn-danger');
                    $(o).text("隐藏");
                }else{
                    $(o).attr("class",'btn btn-success');
                    $(o).text("显示");
                }

            }


        });
    }

    function addImg(id) {
        var pid="{$pid}";
        var url="/admin/product/info_img_add?id="+id+"&pid="+pid;
        layer.open({
            type: 2,
            title: ['上传图片'],//数组第二项可以写任意css样式；如果你不想显示标题栏，你可以title: false
            area:['100%','100%'],
            content:[url],
        });


    }

    function fatherSub(pid){



      var inputarr=  $("input[no='mainorder']");//根据属性值获取元素
        var inputstr="";

        for(var i=0;i<inputarr.length;i++){

          var obj1=$(inputarr[i]);

          var input1="<input name='"+obj1.attr("infoid")+"' value='"+obj1.val()+"'/>";
            inputstr=inputstr+input1;
        }



       // var input2="<input name='pid' value='"+pid+"'/>";
        //inputstr=inputstr+input2;
        $("#mainorder").html(inputstr);

        $("#mainorder").submit();

       //alert(inputarr.length)

    }
</script>






